/*!
\copyright  Copyright (c) 2019-2025 Qualcomm Technologies International, Ltd.
            All Rights Reserved.
            Qualcomm Technologies International, Ltd. Confidential and Proprietary.
\file
\brief      Audio source specific parameters used in the kymera adaptation layer
*/

#ifndef KYMERA_AUDIO_PROTECTED_H_
#define KYMERA_AUDIO_PROTECTED_H_

#include "volume_types.h"
#include "audio_lea_types.h"
#include <stream.h>
#include <a2dp.h>

typedef enum
{
    channel_mode_mono,
    channel_mode_dual_channel,
    channel_mode_stereo,
    channel_mode_joint_stereo
} channel_mode_t;

typedef struct
{
    uint16 * client_lock;
    uint16 client_lock_mask;
    volume_t volume;
    uint8 master_pre_start_delay;
    uint32 rate;
    channel_mode_t channel_mode;
    uint8 seid;
    Sink sink;
    bool content_protection;
    uint8 bitpool;
    uint8 format;
    uint16 remote_mtu;
    uint16 packet_size;
    /*! In bps. Ignored if zero. */
    uint32 max_bitrate;
    /*! Number of bits for each PCM sample. 0 if this is unkown */
    uint8 sample_bit_depth;
    bool q2q_mode;
    aptx_adaptive_ttp_latencies_t nq2q_ttp;
    aptx_ad_version_t aptx_version;
    aptx_ad_supported_features_t aptx_features;
#ifdef ENABLE_LDAC_SINK	
    ldac_params_t ldac_params;
#endif /* ENABLE_LDAC_SINK */	
} a2dp_connect_parameters_t;

typedef struct
{
    Source source;
    uint8 seid;
} a2dp_disconnect_parameters_t;

/* connection parameter for wired analog audio */
typedef struct
{
    volume_t volume;
    uint32 rate;
    uint32 min_latency; /* in micro-seconds */
    uint32 max_latency; /* in micro-seconds */
    uint32 target_latency; /* in micro-seconds */
}wired_analog_connect_parameters_t;

typedef struct
{
    uint8 channels;
    uint8 frame_size;
    Source spkr_src;
    Sink mic_sink;
    volume_t volume;
    bool mute_status;
    uint32 sample_freq;
    uint32 min_latency_ms;
    uint32 max_latency_ms;
    uint32 target_latency_ms;
} usb_audio_connect_parameters_t;

typedef struct
{
    Source source;
    Sink sink;
    void (*kymera_stopped_handler)(Source source);
} usb_audio_disconnect_parameters_t;

typedef struct
{
    /*! ISO handle list information */
    kymera_le_audio_iso_handle_list_t iso_handle_list;

    /*! Media volume parameter \ref volume_t */
    volume_t volume;

    /*! Maximum frame size in octets */
    uint16 frame_length;

     /*! Frame duration in milli seconds */
    uint16 frame_duration;

     /*! Stream type \ref appKymeraLeStreamType */
    appKymeraLeStreamType stream_type;

     /*! Codec type \ref appKymeraLeAudioCodec */
    appKymeraLeAudioCodec codec_type;

    /* Codec id \ref appKymeraLeCodecId */
    appKymeraLeCodecId codec_id;

    /*! Codec version number */
    uint8 codec_version;

    /*! Codec frames per SDU in octects
        Range: 0x0000 to 0x0FFF
        All other values: RFU 
     */
    uint8 codec_frame_blocks_per_sdu;

    /*! TRUE if audio output needs to be muted before starting the input chain to 
        ensure that audio chains consume audio data and play silence on the output
        until the application receives sink synchronised indication, else FALSE.
     */
    bool start_muted;

    /*! TRUE if the context type is Gaming mode, else FALSE.*/
    bool gaming_mode;

    /*! TRUE if the mic chain require CVC such as for gaming mode, else FALSE.*/
    bool use_cvc;

    /*! TRUE if the cis is multi-peripheral, else FALSE.*/
    bool is_multi_peripheral_cis;

#if defined (INCLUDE_LE_AUDIO_BROADCAST_SOURCE) && defined (ENABLE_SIMPLE_SPEAKER)
    /*! transport latency reported for given BIG configuration in milli seconds */
    uint32 transport_latency_big;
#endif
    /*! Sampling frequency in Hertz */
    uint32 sample_rate;

    /*! Presentation delay in micro seconds
        Range: 0x00000000 to 0x00FFFFFF
     */
    uint32 presentation_delay;

    /*! The interested audio channel/s to render, see \ref AudioLocationType */
    uint32 channels_to_render;
} le_media_config_t;

typedef struct
{
    /* Handle used for mono or left channel */
    uint16 source_iso_handle;

    /* Handle used for right channel */
    uint16 source_iso_handle_right;

    /* Sampling frequency in Hertz */
    uint16 sample_rate;

    /* Maximum frame size in octets */
    uint16 frame_length;

    /* Frame duration in milli seconds */
    uint16 frame_duration;

    /*! Presentation delay in micro seconds
        Range: 0x00000000 to 0x00FFFFFF
     */
    uint32 presentation_delay;

    /* Source Audio channel mask for this microphone configuration */
    uint32 audio_channel_mask;

    /* Codec type \ref appKymeraLeAudioCodec */
    appKymeraLeAudioCodec codec_type;

    /* Codec id \ref appKymeraLeCodecId */
    appKymeraLeCodecId codec_id;

    /* Codec version number */
    uint8 codec_version;

    /*! Codec frames per SDU in octects
        Range: 0x0000 to 0x0FFF
        All other values: RFU 
     */
    uint8 codec_frame_blocks_per_sdu;

    /*! Current MIC state 
        0x00 : MIC not muted
        0x01 : MIC muted
        0x02 : MIC mute disabled
     */
    uint8 mic_mute_state;

    /*! TRUE if MIC chain require mic sync, else FALSE */
    bool mic_sync_needed;

    void (*started_handler)(void);
} le_microphone_config_t;

/*
    microphone_present represents either stereo recording is under progress 
    or we have a voice backchannel.
    media_present represents either music streaming or gaming mode.
*/
typedef struct
{
    bool microphone_present;
    bool media_present;
    bool reconfig;
    le_media_config_t media;
    le_microphone_config_t microphone;
} le_audio_connect_parameters_t;

#endif /* KYMERA_AUDIO_PROTECTED_H_ */


